package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

public class RadioButton extends Shape {
   private boolean a;

   RadioButton(ShapeCollection shapes) {
      super(shapes, 12, shapes);
      this.w = new zbtz(this);
   }

   public String getLinkedCell() {
      byte[] var1 = this.u;
      if (var1 == null) {
         GroupBox var2 = this.getGroupBox();
         if (var2 != null) {
            ArrayList var7 = var2.a();
            Iterator var8 = var7.iterator();

            while(var8.hasNext()) {
               Shape var5 = (Shape)var8.next();
               if (var5.getMsoDrawingType() == 12) {
                  var1 = ((RadioButton)var5).u;
                  if (var1 != null) {
                     break;
                  }
               }
            }
         } else {
            Iterator var3 = this.j.iterator();

            while(var3.hasNext()) {
               Shape var4 = (Shape)var3.next();
               if (var4.getMsoDrawingType() == 12 && var4.getGroupBox() == null) {
                  var1 = ((RadioButton)var4).u;
                  if (var1 != null) {
                     break;
                  }
               }
            }
         }

         if (var1 == null) {
            return null;
         }
      }

      String var6 = this.L().b().a(0, var1.length, var1, 0, 0, false);
      return var6 != null && !"".equals(var6) && var6.charAt(0) == '=' ? var6.substring(1) : var6;
   }

   public void setLinkedCell(String value) {
      if (value != null && !"".equals(value)) {
         boolean var2 = false;
         boolean[] var3 = new boolean[]{var2};
         byte[] var4 = zyp.a(this.L(), this.M().getIndex(), value, false, true, false, var3);
         var2 = var3[0];
         if (this.J().k()) {
            GroupBox var5 = this.getGroupBox();
            if (var5 != null) {
               ArrayList var6 = var5.a();
               Iterator var7 = var6.iterator();

               while(var7.hasNext()) {
                  Shape var8 = (Shape)var7.next();
                  if (var8.getMsoDrawingType() == 12) {
                     if (var2) {
                        ((RadioButton)var8).u = var4;
                     } else {
                        ((RadioButton)var8).u = null;
                     }
                  }
               }
            } else {
               Iterator var10 = this.j.iterator();

               while(var10.hasNext()) {
                  Shape var12 = (Shape)var10.next();
                  if (var12.getMsoDrawingType() == 12 && var12.getGroupBox() == null) {
                     if (var2) {
                        ((RadioButton)var12).u = var4;
                     } else {
                        ((RadioButton)var12).u = null;
                     }
                  }
               }
            }
         } else {
            Iterator var9 = this.j.iterator();

            while(var9.hasNext()) {
               Shape var11 = (Shape)var9.next();
               if (var11.getMsoDrawingType() == 12) {
                  if (var2) {
                     ((RadioButton)var11).u = var4;
                  } else {
                     ((RadioButton)var11).u = null;
                  }
               }
            }
         }

      } else {
         this.u = null;
      }
   }

   void a(boolean var1) {
      this.a = var1;
   }

   public boolean isChecked() {
      return this.a;
   }

   public void setChecked(boolean value) {
      if (this.a != value) {
         int var2 = -1;
         if (value) {
            int var3 = 0;
            if (this.J().k()) {
               GroupBox var4 = this.getGroupBox();
               if (var4 != null) {
                  ArrayList var5 = var4.a();
                  Iterator var6 = var5.iterator();

                  while(var6.hasNext()) {
                     Shape var7 = (Shape)var6.next();
                     if (var7.getMsoDrawingType() == 12) {
                        ((RadioButton)var7).a = false;
                        if (var7 == this) {
                           var2 = var3;
                        }

                        ++var3;
                     }
                  }
               } else {
                  Iterator var10 = this.j.iterator();

                  while(var10.hasNext()) {
                     Shape var12 = (Shape)var10.next();
                     if (var12.getMsoDrawingType() == 12 && var12.getGroupBox() == null) {
                        ((RadioButton)var12).a = false;
                        if (var12 == this) {
                           var2 = var3;
                        }

                        ++var3;
                     }
                  }
               }
            } else {
               Iterator var8 = this.j.iterator();

               while(var8.hasNext()) {
                  Shape var11 = (Shape)var8.next();
                  if (var11.getMsoDrawingType() == 12) {
                     ((RadioButton)var11).a = false;
                     if (var11 == this) {
                        var2 = var3;
                     }

                     ++var3;
                  }
               }
            }
         }

         this.a = value;
         if ((value && var2 != -1 || !value) && this.u != null) {
            Cell var9 = this.e(true);
            if (var9 != null) {
               if (value) {
                  var9.putValue(var2 + 1);
               } else {
                  var9.putValue(0);
               }
            }
         }

      }
   }

   public boolean getShadow() {
      return this.z;
   }

   public void setShadow(boolean value) {
      this.z = value;
   }

   void a(RadioButton var1, CopyOptions var2) {
      this.u = var1.u;
      this.a = var1.a;
      super.a((Shape)var1, (CopyOptions)var2);
   }

   public GroupBox getGroupBox() {
      return super.getGroupBox();
   }
}
